package com.gaga.metadata.common.enums;

/**
 * FilterOperatorType
 **/
public enum DbOperatorType {
    COMMA(",", "逗号", ","),
    ADD("+", "加", "+"),
    SUBTRACT("-", "减", "-"),
    MULTIPLY("*", "乘", "*"),
    DIVIDE("/", "除", "/"),
    EQUAL("=", "等于", "="),
    NOTEQUAL("!=", "不等于", null),
    GREATTHAN(">", "大于", ">"),
    LESSTHAN("<", "小于", "<"),
    GREATEQUAL(">=", "大于等于", ">="),
    LESSEQUAL("<=", "小于等于", "<="),

    LEFTBRACKET("(", "左括号", "("),

    RIGHTBRACKET(")", "右括号", ")"),

    SINGLEQUOTES("'", "单引号", "'"),

    AND("and", "且", "and"),
    OR("or", "或", "or"),

    CASE("case", "case", "case"),
    WHEN("when", "当", "when"),

    THEN("then", "然后", "then"),

    ELSE("else", "else", "else"),

    AS("as", "as", "as"),

    END("end", "结束", "end");

    private String code;
    private String desc;
    private String sqlCode;

    DbOperatorType(String code, String desc, String sqlCode) {
        this.code = code;
        this.desc = desc;
        this.sqlCode = sqlCode;
    }

    public String getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    public String getSqlCode() {
        return sqlCode;
    }

    public static DbOperatorType ofCode(String oprCode) {
        for (DbOperatorType dbOperatorType : values()) {
            if (dbOperatorType.code.equalsIgnoreCase(oprCode)) {
                return dbOperatorType;
            }
        }
        return null;
    }

}
